<?php


namespace App\Exception\Handler;


use Swoft\Error\Annotation\Mapping\ExceptionHandler;
use Swoft\Http\Message\Response;
use Swoft\Http\Server\Exception\Handler\AbstractHttpErrorHandler;
use Swoft\Validator\Exception\ValidatorException;
use Throwable;

/**
 * Class ValidatorExceptionHandler
 * @package App\Exception\Handler
 * @ExceptionHandler(ValidatorException::class)
 */
class ValidatorExceptionHandler extends AbstractHttpErrorHandler
{
    /**
     * @inheritDoc
     */
    public function handle(Throwable $e, Response $response): Response
    {
        // TODO: Implement handle() method.
        $data = format([],ERRORS_PARAM,$e->getMessage());

        return $response->withData($data);
    }

}
